{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "Libraries"
      ],
      "metadata": {
        "id": "9We4CppNzzH4"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "!pip install openpyxl\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "Md5F_0AJ01LG",
        "outputId": "c55fb766-ac02-4a9c-85c2-66a5b9a2067f"
      },
      "execution_count": 61,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Requirement already satisfied: openpyxl in /usr/local/lib/python3.10/dist-packages (3.0.10)\n",
            "Requirement already satisfied: et-xmlfile in /usr/local/lib/python3.10/dist-packages (from openpyxl) (1.1.0)\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 62,
      "metadata": {
        "id": "qEjhMr3YlJx2"
      },
      "outputs": [],
      "source": [
        "import numpy as np\n",
        "import pandas as pd\n",
        "import tensorflow\n",
        "from sklearn.model_selection import train_test_split\n",
        "from sklearn.metrics import mean_squared_error, r2_score\n",
        "from sklearn.metrics import mean_absolute_error, mean_squared_error\n",
        "from sklearn.metrics import classification_report"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "Dataset"
      ],
      "metadata": {
        "id": "6Bbk5ptk1m3A"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "df = pd.read_csv(\"df.csv\")"
      ],
      "metadata": {
        "id": "pcHYjPgi0Y9x"
      },
      "execution_count": 78,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "x=df.iloc[:,:-1].values"
      ],
      "metadata": {
        "id": "Auy4aHR11pWd"
      },
      "execution_count": 64,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "y=df.iloc[:,-1].values"
      ],
      "metadata": {
        "id": "ZjrgV-f-2GF-"
      },
      "execution_count": 65,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.2,random_state=0)"
      ],
      "metadata": {
        "id": "y8MjUB4c2p9N"
      },
      "execution_count": 66,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "neural network"
      ],
      "metadata": {
        "id": "7IR4M2EW3Qeu"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "model=tensorflow.keras.models.Sequential()"
      ],
      "metadata": {
        "id": "Y1YH5r_j3S7N"
      },
      "execution_count": 67,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "model.add(tensorflow.keras.layers.Dense(units=6,activation=\"relu\"))"
      ],
      "metadata": {
        "id": "ppzTk0TI4Cfs"
      },
      "execution_count": 68,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "model.add(tensorflow.keras.layers.Dense(units=6,activation=\"relu\"))"
      ],
      "metadata": {
        "id": "HFNa7nRr45m5"
      },
      "execution_count": 69,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "model.add(tensorflow.keras.layers.Dense(units=1))"
      ],
      "metadata": {
        "id": "tmRWa-0_4-nz"
      },
      "execution_count": 70,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "model.compile(optimizer=\"adam\",loss=\"mean_squared_error\")"
      ],
      "metadata": {
        "id": "8IjKMsQb5fGJ"
      },
      "execution_count": 71,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "model.fit(x_train,y_train,epochs=100,batch_size=32)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "I9biMFH66IlQ",
        "outputId": "04829f7e-2b1d-4646-a43b-8434644d187c"
      },
      "execution_count": 72,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Epoch 1/100\n",
            "240/240 [==============================] - 2s 3ms/step - loss: 18891.9082\n",
            "Epoch 2/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 372.1061\n",
            "Epoch 3/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 363.0872\n",
            "Epoch 4/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 351.6482\n",
            "Epoch 5/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 338.2985\n",
            "Epoch 6/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 322.5121\n",
            "Epoch 7/100\n",
            "240/240 [==============================] - 1s 2ms/step - loss: 305.7658\n",
            "Epoch 8/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 286.8841\n",
            "Epoch 9/100\n",
            "240/240 [==============================] - 1s 2ms/step - loss: 267.0470\n",
            "Epoch 10/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 246.2165\n",
            "Epoch 11/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 224.3856\n",
            "Epoch 12/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 201.9735\n",
            "Epoch 13/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 179.4520\n",
            "Epoch 14/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 157.1615\n",
            "Epoch 15/100\n",
            "240/240 [==============================] - 1s 2ms/step - loss: 135.9446\n",
            "Epoch 16/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 115.7659\n",
            "Epoch 17/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 97.5440\n",
            "Epoch 18/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 81.3519\n",
            "Epoch 19/100\n",
            "240/240 [==============================] - 1s 2ms/step - loss: 68.9832\n",
            "Epoch 20/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 58.9876\n",
            "Epoch 21/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 50.7086\n",
            "Epoch 22/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 44.7322\n",
            "Epoch 23/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 39.6667\n",
            "Epoch 24/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 35.7800\n",
            "Epoch 25/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 33.4343\n",
            "Epoch 26/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 31.3399\n",
            "Epoch 27/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 30.3849\n",
            "Epoch 28/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 29.8996\n",
            "Epoch 29/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 28.8913\n",
            "Epoch 30/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 28.5701\n",
            "Epoch 31/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 28.9188\n",
            "Epoch 32/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 28.1954\n",
            "Epoch 33/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 28.7027\n",
            "Epoch 34/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.7077\n",
            "Epoch 35/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.7196\n",
            "Epoch 36/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.7813\n",
            "Epoch 37/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.8028\n",
            "Epoch 38/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.7371\n",
            "Epoch 39/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.1614\n",
            "Epoch 40/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.6717\n",
            "Epoch 41/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.4455\n",
            "Epoch 42/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.3662\n",
            "Epoch 43/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.1483\n",
            "Epoch 44/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.0365\n",
            "Epoch 45/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.3801\n",
            "Epoch 46/100\n",
            "240/240 [==============================] - 1s 2ms/step - loss: 26.6723\n",
            "Epoch 47/100\n",
            "240/240 [==============================] - 1s 2ms/step - loss: 28.1486\n",
            "Epoch 48/100\n",
            "240/240 [==============================] - 1s 2ms/step - loss: 27.1633\n",
            "Epoch 49/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 26.8588\n",
            "Epoch 50/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 27.7017\n",
            "Epoch 51/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 26.8519\n",
            "Epoch 52/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 27.2500\n",
            "Epoch 53/100\n",
            "240/240 [==============================] - 1s 2ms/step - loss: 28.3920\n",
            "Epoch 54/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.5960\n",
            "Epoch 55/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.4172\n",
            "Epoch 56/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 26.9658\n",
            "Epoch 57/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 26.9705\n",
            "Epoch 58/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.2041\n",
            "Epoch 59/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 26.9342\n",
            "Epoch 60/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.3654\n",
            "Epoch 61/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 26.9761\n",
            "Epoch 62/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 26.4546\n",
            "Epoch 63/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 26.6626\n",
            "Epoch 64/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.4862\n",
            "Epoch 65/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.1455\n",
            "Epoch 66/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 26.9684\n",
            "Epoch 67/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 26.8070\n",
            "Epoch 68/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 27.2543\n",
            "Epoch 69/100\n",
            "240/240 [==============================] - 1s 2ms/step - loss: 26.6273\n",
            "Epoch 70/100\n",
            "240/240 [==============================] - 1s 2ms/step - loss: 26.7146\n",
            "Epoch 71/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 26.9732\n",
            "Epoch 72/100\n",
            "240/240 [==============================] - 1s 2ms/step - loss: 26.9019\n",
            "Epoch 73/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 27.0174\n",
            "Epoch 74/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 26.8273\n",
            "Epoch 75/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 27.4103\n",
            "Epoch 76/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 27.5924\n",
            "Epoch 77/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 26.7646\n",
            "Epoch 78/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.6109\n",
            "Epoch 79/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.3981\n",
            "Epoch 80/100\n",
            "240/240 [==============================] - 1s 2ms/step - loss: 26.7007\n",
            "Epoch 81/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.2811\n",
            "Epoch 82/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.1437\n",
            "Epoch 83/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.5796\n",
            "Epoch 84/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.1708\n",
            "Epoch 85/100\n",
            "240/240 [==============================] - 1s 2ms/step - loss: 26.5357\n",
            "Epoch 86/100\n",
            "240/240 [==============================] - 1s 2ms/step - loss: 26.7545\n",
            "Epoch 87/100\n",
            "240/240 [==============================] - 1s 2ms/step - loss: 27.4954\n",
            "Epoch 88/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 26.8839\n",
            "Epoch 89/100\n",
            "240/240 [==============================] - 1s 2ms/step - loss: 27.7122\n",
            "Epoch 90/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.2991\n",
            "Epoch 91/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 26.5668\n",
            "Epoch 92/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.3938\n",
            "Epoch 93/100\n",
            "240/240 [==============================] - 1s 2ms/step - loss: 26.4718\n",
            "Epoch 94/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 26.8271\n",
            "Epoch 95/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.4552\n",
            "Epoch 96/100\n",
            "240/240 [==============================] - 0s 2ms/step - loss: 27.3914\n",
            "Epoch 97/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 26.8037\n",
            "Epoch 98/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 27.6068\n",
            "Epoch 99/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 26.8178\n",
            "Epoch 100/100\n",
            "240/240 [==============================] - 1s 3ms/step - loss: 27.0809\n"
          ]
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "<keras.callbacks.History at 0x7d2bcab69060>"
            ]
          },
          "metadata": {},
          "execution_count": 72
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "model.summary()"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "6BEkt3xN_Fgx",
        "outputId": "3ed39ad9-8cbd-4c2c-d322-f67824363224"
      },
      "execution_count": 77,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Model: \"sequential_3\"\n",
            "_________________________________________________________________\n",
            " Layer (type)                Output Shape              Param #   \n",
            "=================================================================\n",
            " dense_6 (Dense)             (None, 6)                 30        \n",
            "                                                                 \n",
            " dense_7 (Dense)             (None, 6)                 42        \n",
            "                                                                 \n",
            " dense_8 (Dense)             (None, 1)                 7         \n",
            "                                                                 \n",
            "=================================================================\n",
            "Total params: 79\n",
            "Trainable params: 79\n",
            "Non-trainable params: 0\n",
            "_________________________________________________________________\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "y_pred=model.predict(x_test)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "GRDj7P4B7H4X",
        "outputId": "eb6df03b-52c8-4a28-f150-8d081ca85544"
      },
      "execution_count": 73,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "60/60 [==============================] - 0s 1ms/step\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "np.set_printoptions(precision=4)\n",
        "print(np.concatenate((y_pred.reshape(len(y_pred),1), y_test.reshape(len(y_test),1)),1))"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "0OpwE4h_9Q2i",
        "outputId": "23f712f9-9db3-46e5-96a6-9d95b030121a"
      },
      "execution_count": 74,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "[[432.1042 431.23  ]\n",
            " [463.1646 460.01  ]\n",
            " [466.6829 461.14  ]\n",
            " ...\n",
            " [473.9019 473.26  ]\n",
            " [440.6333 438.    ]\n",
            " [459.8633 463.28  ]]\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "\n",
        "mse = mean_squared_error(y_test, y_pred)\n",
        "\n",
        "rmse = mean_squared_error(y_test, y_pred, squared=False)\n",
        "\n",
        "\n",
        "r2 = r2_score(y_test, y_pred)\n",
        "\n",
        "print(\"Mean Absolute Error (MAE):\", mean_absolute_error(y_test, y_pred))\n",
        "print(\"Mean Squared Error (MSE):\", mse)\n",
        "print(\"Root Mean Squared Error (RMSE):\", rmse)\n",
        "print(\"R-squared (R2) score:\", r2)\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "c2gZnKLO9oJr",
        "outputId": "4bb6cf56-d275-4f01-8cd7-3c46d3e9b958"
      },
      "execution_count": 75,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Mean Absolute Error (MAE): 4.022176704366877\n",
            "Mean Squared Error (MSE): 25.210623634126183\n",
            "Root Mean Squared Error (RMSE): 5.021018186994166\n",
            "R-squared (R2) score: 0.9138062491015191\n"
          ]
        }
      ]
    }
  ]
}